<div class="panel panel-default">
	<div class="panel-heading">
		<div class="row">
			<div class="col-md-6"><h4>Data Prestasi Siswa</h4></div>
			<div class="col-md-4">
				<div class="input-group">
					<input type="text" class="form-control" id="prestasi_searchtext">
					<span class="input-group-btn">
						<button class="btn btn-default" type="button" id="prestasi_refresh">X</button>
						<button class="btn btn-default" type="button" id="prestasi_search">Search!</button>
					</span>
				</div>
			</div>
			<div class="col-md-2"><button class="btn btn-default" id="prestasi_add">Tambah Data</button></div>
		</div>
	</div>
	<div id="prestasi_grid"></div>
</div>
<script type="text/javascript">
	$(document).ready(function () {
	
		var prestasi_grid = $('#prestasi_grid');
		var prestasi_add = $('#prestasi_add');
		var prestasi_search = $('#prestasi_search');
		var prestasi_refresh = $('#prestasi_refresh');
		var prestasi_searchtext = $('#prestasi_searchtext');
	
		prestasi_refresh.hide();
		
		function search(){
			var searchText = prestasi_searchtext.val();
			prestasi_refresh.show();
			prestasi_grid.jtable('load',{
				searchText : searchText
			});
		}
		
		prestasi_searchtext.keypress(function(e) {
			if(e.which == 13) {
				e.preventDefault();
				search();
			}
		});
		prestasi_search.click(function(e){
			e.preventDefault();
			search();
		});
		prestasi_refresh.click(function(e){
			e.preventDefault();
			prestasi_searchtext.val('');
			prestasi_grid.jtable('load',{
				searchText : ''
			});
			prestasi_refresh.hide();
		});
	
		prestasi_grid.jtable({
			addRecordButton : prestasi_add,
			paging: true,
			pageSize: 15,
			columnSize:2,
			sorting: true,
			actions: {
				listAction: 'c_prestasi/data_list',
				createAction: 'c_prestasi/create',
				updateAction: 'c_prestasi/update',
				deleteAction: 'c_prestasi/delete'
			},
			fields: {
				id_prestasi : {
					key: true,
					create: false,
					edit: false,
					list: false
				},
				nama_siswa : {
					title: 'Nama Siswa',
					width: '20%'
				},
				nis : {
					title: 'NIS',
					width: '10%'
				},
				id_sekolah : {
					title: 'Sekolah',
					width: '10%'
				},
				peringkat : {
					title: 'Peringkat',
					width: '10%'
				},
				kompetisi : {
					title: 'Kompetisi',
					width: '10%'
				},
				id_semester : {
					title: 'Id Semester',
					width: '10%'
				},
				tahun_ajar : {
					title: 'Tahun Ajar',
					width: '10%'
				},
				foto : {
					title: 'Foto',
					width: '10%',
					visibility : 'hidden'
				},
				tanggal: {
					title: 'Tanggal',
					width: '10%',
					type: 'date',
					create: false,
					edit: false,
					visibility : 'hidden'
				}
			}
		});
		prestasi_grid.jtable('load');
	});
</script>